#include<cstdio>
using namespace std;
int n,ans[200001],cnt;
struct node
{
	int i,f,x;
}a[200001],zz[200001];
void print(int num)
{
	for(int i=1;i<=num;i++){
		int Sum=0;
		for(int j=1;j<=cnt;j++){
			Sum+=ans[j-1];
			printf("%d ",a[i+Sum].i);
		}
		printf("\n");
	}
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].f);
		a[i].i=i;
	}
	int p=a[1].f,sum=0;
	for(int i=1;i<=n;i++){
		if(a[i].f!=p){
			ans[++cnt]=sum;
			a[i].x=1;
			sum=1;
			p=a[i].f;
		}
		else
			a[i].x=++sum;
	}
	ans[++cnt]=sum;
	while(n){
		int p=a[1].f,sum=0;
		cnt=0;
		for(int i=1;i<=n;i++){
			if(a[i].f!=p){
				ans[++cnt]=sum;
				a[i].x=1;
				sum=1;
				p=a[i].f;
			}
			else
				a[i].x=++sum;
		}
		ans[++cnt]=sum;
		a[n].x=sum;
		int minn=1e9;
		for(int i=1;i<=cnt;i++){
			if(minn>ans[i])
				minn=ans[i];
		}
		print(minn);
		int tmp=0;
		for(int i=1;i<=n;i++){
			if(a[i].x>minn){
				zz[++tmp].x=a[i].x-minn;
				zz[tmp].i=a[i].i;
				zz[tmp].f=a[i].f;
			}
		}
		for(int i=1;i<=tmp;i++){
			a[i]=zz[i];
			a[i].x=zz[i].x;
			a[i].i=zz[i].i;
			a[i].f=zz[i].f;
		}
		n=tmp;
	}
	return 0;
}
